
<template>
  <div class="jeepay-m-center" style="margin-top: 5px; margin-left: 20px;">
    <a-steps v-show="(vdata.showStyle == showStyleEnum.step) && !isMobile" :current="vdata.currentStep - 1" type="navigation">
      <a-step title="主体信息" />
      <a-step title="经营信息" />
      <a-step title="结算账户" />
    </a-steps>
    <a-divider v-show="!isMobile" />
    <a-divider v-show="isMobile" class="jeepay-m-divider" orientation="left" style="color: #1A66FF;"><span style="color: #2980FD;">{{ vdata.currentStep }}</span>/{{ vdata.steps.length }} {{ vdata.steps[vdata.currentStep - 1] }}</a-divider>
    <!-- 1. 主体信息  -->
    <a-form
      v-show="vdata.showStyle == showStyleEnum.block || vdata.currentStep == 1"
      ref="stepForm1Ref"
      style="margin-top: 20px;"
      :model="applymentDetailInfo"
      :label-col="{ span: 4 }"
      :wrapper-col="{ span: 8 }"
      :rules="vdata.step1Rules"
    >
      <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">基础项</a-divider>

      <a-form-item label="主体类型" name="merchantType">
        <a-radio-group v-model:value="applymentDetailInfo.merchantType" @change="mchTypeChange()">
          <a-radio :value="1">小微商户</a-radio>
          <a-radio :value="2">个体工商户</a-radio>
          <a-radio :value="3">企业</a-radio>
        </a-radio-group>
      </a-form-item>
      
      <div v-if="applymentDetailInfo.merchantType == '2' || applymentDetailInfo.merchantType == '3'">
        <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">营业执照信息</a-divider>
        <a-form-item label="营业执照照片" name="licenseImg">
          <JeepayUpload v-model:src="applymentDetailInfo.licenseImg" bizType="applyment" ocrType="license" @ocrScan="ocrScanFunc" />
          <span class="jeepay-tip-text">(上传图片自动识别：营业执照编号、商户全称、经营详细地址，识别出来的具体内容商户可自行修改)</span>
        </a-form-item>

        <a-form-item label="营业执照编号" name="licenseNo">
          <a-input v-model:value.trim="applymentDetailInfo.licenseNo" />
        </a-form-item>
      </div>
      
      <a-form-item label="商户注册名称" name="mchFullName">
        <a-input v-model:value.trim="applymentDetailInfo.mchFullName" />
      </a-form-item>
     
      <a-form-item label="商户简称" name="mchShortName">
        <a-input v-model:value.trim="applymentDetailInfo.mchShortName" maxlength="20" show-count />
      </a-form-item> 

      <div v-if="applymentDetailInfo.merchantType == '2' || applymentDetailInfo.merchantType == '3'">
        <a-form-item label="经营范围" name="licenseBusiness">
          <a-textarea v-model:value="applymentDetailInfo.licenseBusiness" />
        </a-form-item>

        <a-form-item label="注册地址" name="licenseAddress">
          <a-input v-model:value.trim="applymentDetailInfo.licenseAddress" />
        </a-form-item>

        <a-form-item label="营业执照起始有效期" name="licenseEffectBegin">
          <a-input v-model:value.trim="applymentDetailInfo.licenseEffectBegin" />
        </a-form-item>

        <a-form-item class="jeepay-valid" label="营业执照有效期截止" name="licenseEffectEnd">
          <a-input v-model:value.trim="applymentDetailInfo.licenseEffectEnd" :disabled="applymentDetailInfo.licenseEffectEnd == '长期'" style="width: 150px;margin-right: 10px;" />
          <a-checkbox :checked="applymentDetailInfo.licenseEffectEnd == '长期' " @change="(e) => applymentDetailInfo.licenseEffectEnd = e.target.checked ? '长期' : '' ">长期</a-checkbox>
        </a-form-item>
      </div>

      <!-- 法人信息 -->
      <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">法定代表人证件</a-divider>
      
      <a-form-item label="法人身份证人像面照片" name="idcard1Img">
        <JeepayUpload v-model:src="applymentDetailInfo.idcard1Img" bizType="applyment" ocrType="idCard" @ocrScan="ocrScanByAccountFunc" />
        <span class="jeepay-tip-text">(上传图片自动识别 身份证名称 身份证号) <br>注：原件相片或复印件盖章（个体工商户或小微盖手印）</span>
      </a-form-item>

      <a-form-item label="法人身份证国徽面照片" name="idcard2Img">
        <JeepayUpload v-model:src="applymentDetailInfo.idcard2Img" bizType="applyment" ocrType="idCard" @ocrScan="ocrScanByAccountFunc" />
        <span class="jeepay-tip-text">(上传图片自动识别 有效期)</span>
      </a-form-item>
      
      <a-form-item label="法人姓名" name="idcardName">
        <a-input v-model:value.trim="applymentDetailInfo.idcardName" />
      </a-form-item>

      <a-form-item label="法人手机号码" name="legalPersonPhone">
        <a-input v-model:value.trim="applymentDetailInfo.legalPersonPhone" />
      </a-form-item>

      <a-form-item label="法人身份证号" name="idcardNo">
        <a-input v-model:value.trim="applymentDetailInfo.idcardNo" />
      </a-form-item>

      <a-form-item label="法人身份证地址" name="idcardAddress">
        <a-input v-model:value.trim="applymentDetailInfo.idcardAddress" />
      </a-form-item>

      <a-form-item label="法人身份证有效期开始日期" name="idcardEffectBegin">
        <a-input v-model:value.trim="applymentDetailInfo.idcardEffectBegin" />
      </a-form-item>
        
      <a-form-item class="jeepay-valid" label="法人身份证有效期结束日期" name="idcardEffectEnd">
        <a-input v-model:value.trim="applymentDetailInfo.idcardEffectEnd" :disabled="applymentDetailInfo.idcardEffectEnd == '长期'" style="width: 150px;margin-right: 10px;" />
        <a-checkbox :checked="applymentDetailInfo.idcardEffectEnd == '长期' " @change="(e) => applymentDetailInfo.idcardEffectEnd = e.target.checked ? '长期' : '' ">长期</a-checkbox>
      </a-form-item>
    </a-form>

    <!-- 2. 经营信息  -->
    <a-form
      v-show="vdata.showStyle == showStyleEnum.block || vdata.currentStep == 2"
      ref="stepForm2Ref"
      :model="applymentDetailInfo"
      :label-col="{ span: 4 }"
      :wrapper-col="{ span: 8 }"
      :rules="vdata.step2Rules"
    >
      <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">经营信息</a-divider>
      
      <a-row v-if="props.applyType == '0'">
        <a-col offset="2" span="10">
          <a-alert type="info">
            <template #message>
              <a-button type="link">分账接收方无需上送经营信息</a-button>
            </template>
          </a-alert>
        </a-col>
      </a-row>

      <div v-if="props.applyType == '1'">
        <a-form-item label="商户经营地省市区" name="areaCode">
          <JeepayAreaSelect v-model:value="applymentDetailInfo.areaCode" @change="searchAreaFunc" />
        </a-form-item>
        <a-form-item label="商户经营详细地址" name="address">
          <a-input v-model:value.trim="applymentDetailInfo.address" minlength="10" maxlength="80" show-count />
          <span class="jeepay-tip-text">(长度须在10~80的范围内)</span>
        </a-form-item>
        <a-form-item label="商户类别（行业）" name="mccCode">
          <JeepayMccSelect v-model:value="applymentDetailInfo.mccCode" />
        </a-form-item>

        <a-form-item label="微信经营类目" name="wxMccCode">
          <JeepayEpspayWxSelect v-model:value="applymentDetailInfo.wxMccCode" :merchantType="applymentDetailInfo.merchantType" />
          <span class="jeepay-tip-text">(开通微信支付时必填)</span>
        </a-form-item>
        <a-form-item label="支付宝经营类目" name="aliMccCode">
          <JeepayHmpayMchMccSelect v-model:value="applymentDetailInfo.aliMccCode" />
          <span class="jeepay-tip-text">(开通支付宝支付时必填)</span>
        </a-form-item>

        <a-form-item label="注册资本" name="registeredCapital">
          <a-input-number v-model:value.trim="applymentDetailInfo.registeredCapital" style="display: block;" :precision="0" :min="0" addon-after="元" />
          <span class="jeepay-tip-text">(不填时当0处理)</span>
        </a-form-item> 
        <a-form-item label="门店门头照" name="storeOuterImg">
          <JeepayUpload v-model:src="applymentDetailInfo.storeOuterImg" bizType="applyment" />
        </a-form-item>
        <a-form-item label="门店内景照" name="storeInnerImg">
          <JeepayUpload v-model:src="applymentDetailInfo.storeInnerImg" bizType="applyment" />
        </a-form-item>
        <a-form-item label="门店收银台照" name="storeCashierImg">
          <JeepayUpload v-model:src="applymentDetailInfo.storeCashierImg" bizType="applyment" />
        </a-form-item>
      </div>

      <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">联系人信息</a-divider>
      <a-button shape="round" style="margin-left: 40%; margin-bottom:10px " type="primary" @click="isLegal('contact')">
        <arrow-right-outlined />
        点此使用法人信息
      </a-button>

      <a-form-item label="联系人姓名" name="contactName">
        <a-input v-model:value.trim="applymentDetailInfo.contactName" />
      </a-form-item>
      <a-form-item label="联系人手机号" name="contactPhone">
        <a-input v-model:value.trim="applymentDetailInfo.contactPhone" />
      </a-form-item>
      <a-form-item v-if="props.applyType == '1'" label="客服电话" name="serviceTel">
        <a-input v-model:value.trim="applymentDetailInfo.serviceTel" />
      </a-form-item>
      <a-form-item v-if="props.applyType == '1'" label="邮箱地址" name="contactEmail">
        <a-input v-model:value.trim="applymentDetailInfo.contactEmail" />
      </a-form-item>
    </a-form>
    

    <!-- 3. 结算账户  -->
    <a-form
      v-show="vdata.showStyle == showStyleEnum.block || vdata.currentStep == 3"
      ref="stepForm3Ref"
      :model="applymentDetailInfo"
      :label-col="{ span: 4 }"
      :wrapper-col="{ span: 8 }"
      :rules="vdata.step3Rules"
    >
      <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">账户信息</a-divider>

      <a-form-item label="结算账户类型" name="settAccountType">
        <a-radio-group v-model:value="applymentDetailInfo.settAccountType" :disabled="applymentDetailInfo.merchantType == '1'">
          <a-radio value="B">对公账户</a-radio>
          <a-radio value="B2">授权对公</a-radio>
          <a-radio value="C">法人账户</a-radio>
          <a-radio value="C2">授权对私</a-radio>
        </a-radio-group>
      </a-form-item>

      <a-form-item label="银行卡正面照" name="settAccountLicenseImg">
        <JeepayUpload v-model:src="applymentDetailInfo.settAccountLicenseImg" bizType="applyment" ocrType="bankCard" @ocrScan="ocrScanBySettAccountBankCardFunc" />
        <span class="jeepay-tip-text">(上传图片自动识别 银行卡号)</span>
      </a-form-item>

      <a-form-item label="开户银行名称" name="settAccountBankName">
        <a-input v-model:value.trim="applymentDetailInfo.settAccountBankName" />
      </a-form-item>

      <a-form-item label="结算账户号" name="settAccountNo">
        <a-input v-model:value.trim="applymentDetailInfo.settAccountNo" />
        <span class="jeepay-tip-text">(对私时传银行卡号，对公时传开户账号)</span>
      </a-form-item>

      <a-form-item label="结算账户名" name="settAccountName">
        <a-input v-model:value.trim="applymentDetailInfo.settAccountName" />
      </a-form-item> 

      <div v-if="applymentDetailInfo.settAccountType == 'B'">
        <a-form-item label="开户行联行号" name="openBankCode">
          <a-input v-model:value.trim="applymentDetailInfo.openBankCode" placeholder="联行号" />
          <span><a href="https://www.icvio.cn/" target="_blank">联行号及开户支行名称查询</a></span>
        </a-form-item>
        <a-form-item label="开户支行名称" name="settAccountBankBranchName">
          <a-input v-model:value.trim="applymentDetailInfo.settAccountBankBranchName" placeholder="开户支行名称" />
          <span class="jeepay-tip-text">(即结算卡开户银行网点名称，例如：中国工商银行股份有限公司北京东铁匠营支行)</span>
        </a-form-item>
      </div>

      <!-- 结算账户附件 -->
      <a-form-item v-if="applymentDetailInfo.settAccountType == 'B2' || applymentDetailInfo.settAccountType == 'C2'" label="结算账户附件" name="settleAttachment">
        <JeepayUploadBatch v-model:fileList="applymentDetailInfo.settleAttachment" bizType="applyment" listType="picture-card" />
        <span class="jeepay-tip-text">(如非法人结算授权书，上传图片，会自动打包成zip上送)</span>
      </a-form-item>

      <a-form-item v-if="applymentDetailInfo.settAccountType == 'C'" label="银行预留手机号" name="prePhone">
        <a-input v-model:value.trim="applymentDetailInfo.prePhone" />
      </a-form-item>
    
      
      <!-- 协议信息 -->
      <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">协议信息</a-divider>
      
      <a-form-item label="是否已签约协议书" name="contractStatus">
        <a-radio-group v-model:value="applymentDetailInfo.contractStatus">
          <a-radio value="1">是</a-radio>
          <a-radio value="0">否</a-radio>
        </a-radio-group>
      </a-form-item>
      <a-form-item v-if="applymentDetailInfo.contractStatus == '1'" label="协议书盖章页/签名页附件" name="contractAttachment">
        <JeepayUpload v-model:src="applymentDetailInfo.contractAttachment" bizType="applyment" />
      </a-form-item>

      <div v-if="applymentDetailInfo.merchantType == '3'">
        <!-- 企业类型需上送 -->
        <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">对公户信息</a-divider>
        <a-form-item label="开户许可证账户名" name="companyAccountName">
          <a-input v-model:value.trim="applymentDetailInfo.companyAccountName" />
        </a-form-item>
        <a-form-item label="开户许可证账号" name="companyAccountNo">
          <a-input v-model:value.trim="applymentDetailInfo.companyAccountNo" />
        </a-form-item>
        <a-form-item label="开户银行" name="companyAccountBankName">
          <a-input v-model:value.trim="applymentDetailInfo.companyAccountBankName" />
        </a-form-item>
        <a-form-item label="开户支行" name="companyAccountBankBranchName">
          <a-input v-model:value.trim="applymentDetailInfo.companyAccountBankBranchName" />
        </a-form-item>
        <a-form-item v-if="applymentDetailInfo.settAccountType == 'B'" label="开户申请表/开户许可证照片" name="companyAccountLicenseImg">
          <JeepayUpload v-model:src="applymentDetailInfo.companyAccountLicenseImg" bizType="applyment" />
        </a-form-item>
      </div>
      
      <!-- 结算人信息 -->
      <div v-if="applymentDetailInfo.merchantType != '1' && applymentDetailInfo.settAccountType == 'C2'">
        <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">结算人信息</a-divider>
      
        <a-form-item label="结算人身份证人像面照片" name="settAccountIdcard1Img">
          <JeepayUpload v-model:src="applymentDetailInfo.settAccountIdcard1Img" bizType="applyment" />
        </a-form-item>
        <a-form-item label="结算人身份证国徽面照片" name="settAccountIdcard2Img">
          <JeepayUpload v-model:src="applymentDetailInfo.settAccountIdcard2Img" bizType="applyment" />
        </a-form-item>
        
        <a-form-item label="转账功能开通申请书附件图片" name="transferApplyAttachment">
          <JeepayUpload v-model:src="applymentDetailInfo.transferApplyAttachment" bizType="applyment" />
        </a-form-item>
      </div>
      
      
      <!-- 产品费率 -->
      <a-divider class="jeepay-m-divider" orientation="left" style="color: #1A66FF;">产品费率</a-divider>

      <div label="配置费率" name="fee" style="width:100%;">
        <JeepayPaywayRatePanel 
          ref="jeepayPaywayRatePanelRef"
          :configMode="configMode"
          :infoId=" (mchApplymentData.applyId || '') + '_' + mchApplymentData.mchNo" 
          :selectIfCode="mchApplymentData.ifCode"
          onlyRate="true"
        />
      </div>
    </a-form>
    <a-divider />

    <div class="jeepay-btn-box jeepay-m-btn-box" style="margin-top: 50px; margin-bottom: 50px;text-align: center;">
      <a-button v-show="vdata.showStyle == showStyleEnum.step && vdata.currentStep > 1" class="jeepay-m-btn" data-type="inline" type="primary" @click="toPrevStep"><left-circle-outlined /> 上一步 </a-button>
      <a-button v-show="vdata.showStyle == showStyleEnum.step && vdata.currentStep < 3" class="jeepay-m-btn" data-type="inline" type="primary" @click="toNextStep">下一步 <right-circle-outlined /> </a-button>
    </div>
  </div>
</template>

<script setup lang="ts">

import {reactive, getCurrentInstance, defineEmits, inject, ref} from 'vue'
import ruleGenerator from '@/utils/ruleGenerator'

// 定义 父组件传参
const props = defineProps({
  applyType: { type: String, default: '1' }, // 进件申请单类型 0-分账 1-进件；
})

const jeepayPaywayRatePanelRef = ref()

// 获取当前实例的代理对象
const { proxy } : any = getCurrentInstance()

const { $infoBox } = getCurrentInstance()!.appContext.config.globalProperties


// 显示类型枚举值
const showStyleEnum = {
  step: 'step',
  block: 'block'
}

// emit： 向父组件进行通讯。 
const emit = defineEmits(['itemRender'])

// 参数注入： 是否手机端
let isMobile : any = inject('isMobile')

// 响应式数据
const vdata : any = reactive({
  showStyle: 'step', // 显示类型： step-分步,  block-整页显示 
  steps: ['主体信息', '经营信息', '结算账户'],
  isTempData: false, // 是否保存草稿
  isvDefaultPaywayFee: {} as any, // 服务商默认费率
  currentStep: 1,
  receiverTableData: [] as any,
  branchBankList:[] as any, // 支行列表
  step1Rules: {
                merchantType: [ ruleGenerator.requiredSelect('商户类型', 'number') ],
                mchShortName: [ ruleGenerator.requiredInput('商户简称') ],
                licenseImg: [ ruleGenerator.requiredUpload('营业执照照片') ],
                licenseNo: [ ruleGenerator.requiredInput('营业执照编号') ],
                mchFullName: [ ruleGenerator.requiredInput('商户注册名称') ],
                licenseBusiness: [ ruleGenerator.requiredInput('经营范围') ],
                licenseAddress: [ ruleGenerator.requiredInput('营业执照经营详细地址') ],
                companyAccountName: [ ruleGenerator.requiredInput('开户许可证账户名') ],
                companyAccountNo: [ ruleGenerator.requiredInput('开户许可证账号') ],
                companyAccountBankName: [ ruleGenerator.requiredInput('开户银行') ],
                companyAccountBankBranchName: [ ruleGenerator.requiredInput('开户支行') ],
                licenseEffectBegin: [ ruleGenerator.requiredInput('营业执照起始有效期'), ruleGenerator.date ],
                licenseEffectEnd: [ ruleGenerator.requiredInput('营业执照有效期截止'), ruleGenerator.dateOrForever ],
                idcard1Img: [ ruleGenerator.requiredUpload('法人身份证人像面') ],
                idcard2Img: [ ruleGenerator.requiredUpload('法人身份证国徽面') ],
                idcardName: [ ruleGenerator.requiredInput('法人姓名') ],
                legalPersonPhone: [ ruleGenerator.requiredInput('法人手机号码') ],
                idcardNo: [ ruleGenerator.requiredInput('法人身份证号') ],
                idcardAddress: [ ruleGenerator.requiredInput('法人身份证地址') ],
                idcardEffectBegin: [ ruleGenerator.requiredInput('法人身份证有效期开始日期') ],
                idcardEffectEnd: [ ruleGenerator.requiredInput('法人身份证有效期结束日期') ]
              },
  step2Rules: {
                serviceTel: [ ruleGenerator.requiredInput('客服电话') ],
                contactEmail: [ ruleGenerator.requiredInput('邮箱地址') ],
                storeOuterImg: [ ruleGenerator.requiredUpload('门店门头照') ],
                storeInnerImg: [ ruleGenerator.requiredUpload('门店内景照') ],
                mccCode: [ ruleGenerator.requiredSelect('商户类别') ],
                areaCode: [ ruleGenerator.requiredSelect('商户经营地省市区', 'array') ],
                address: [ ruleGenerator.requiredInput('商户经营详细地址') ],
                contactName: [ ruleGenerator.requiredInput('联系人姓名') ],
                contactPhone: [ ruleGenerator.requiredInput('联系人手机号') ]
  },
  step3Rules: {
                settleWay: [ ruleGenerator.requiredSelect('结算周期', 'string') ],
                settAccountType: [ ruleGenerator.requiredSelect('结算账户类型', 'string') ],
                settAccountLicenseImg: [ ruleGenerator.requiredUpload('银行卡正面照') ],
                settAccountBankName: [ ruleGenerator.requiredInput('开户银行名称') ],
                settAccountNo: [ ruleGenerator.requiredInput('结算账户号') ],
                settAccountName: [ ruleGenerator.requiredInput('结算账户名') ],
                openBankCode: [ ruleGenerator.requiredInput('开户行联行号') ],
                settAccountBankBranchName: [ ruleGenerator.requiredInput('开户支行名称') ],
                settleAttachment: [ ruleGenerator.requiredUpload('非法人结算授权书') ],
                contractStatus: [ ruleGenerator.requiredSelect('是否已签约协议书', 'string') ],
                contractAttachment: [ ruleGenerator.requiredUpload('协议书盖章页/签名页附件照片') ],
                settAccountIdcard1Img: [ ruleGenerator.requiredUpload('结算人身份证人像面照片') ],
                settAccountIdcard2Img: [ ruleGenerator.requiredUpload('结算人身份证国徽面照片') ],
                transferApplyAttachment: [ ruleGenerator.requiredUpload('转账功能开通申请书附件照片') ]
  }
})

// 接收进件参数(包含 商户号， ifCode )
let mchApplymentDataRef : any = inject('mchApplymentData')
let mchApplymentData : any = mchApplymentDataRef.value

// 接收父组件的进件详细参数
let applymentDetailInfoInject : any = inject('applymentDetailInfo')
let applymentDetailInfo : any = applymentDetailInfoInject.value

// 参数注入： 配置方式
let configMode : any = inject('configMode')


// 下一步
function toNextStep() {
  // 验证是否通过
  proxy.$refs['stepForm'+vdata.currentStep+'Ref'].validate().then( () => {
      vdata.currentStep ++
  })
  if (!applymentDetailInfo.settleWay) {
    applymentDetailInfo.settleWay = '01'
  }
}

// 上一步
function toPrevStep(){
  vdata.currentStep --
}

function validateAllForm(step: number){
  return proxy.$refs['stepForm'+step+'Ref'].validate().then( () => {
     if(step >= 3){
      return Promise.resolve()
     }
     return validateAllForm(++step)
     
  })
}

if(applymentDetailInfo.feeData) {
  vdata.receiverTableData = applymentDetailInfo.feeData
}

// 图片识别的回调函数  营业执照
function ocrScanFunc(orcObject){
  if(orcObject){
    if(orcObject.licenseNo){
      applymentDetailInfo.licenseNo = orcObject.licenseNo
    }
    if(orcObject.mchFullName){
      applymentDetailInfo.mchFullName = orcObject.mchFullName
    }
    if(orcObject.licenseAddress){
      applymentDetailInfo.licenseAddress = orcObject.licenseAddress
    }
    if(orcObject.licenseBusiness){
      applymentDetailInfo.licenseBusiness = orcObject.licenseBusiness
    }
    if(orcObject.licenseEffectBegin){
      applymentDetailInfo.licenseEffectBegin = orcObject.licenseEffectBegin
    }
    if(orcObject.licenseEffectEnd){
      applymentDetailInfo.licenseEffectEnd = orcObject.licenseEffectEnd
    }
  }
}

// 识别银行卡信息 
function ocrScanBySettAccountBankCardFunc(orcObject){
  if(orcObject){
    if(orcObject.settAccountNo){
      applymentDetailInfo.settAccountNo = orcObject.settAccountNo
    }
    if(orcObject.settAccountBankName){
      applymentDetailInfo.settAccountBankName = orcObject.settAccountBankName
    }
  }
}

// 图片识别的回调函数  法人身份证
function ocrScanByAccountFunc(orcObject){
  if(orcObject){
    if(orcObject.idcardName){
      applymentDetailInfo.idcardName = orcObject.idcardName
    }
    if(orcObject.idcardNo){
      applymentDetailInfo.idcardNo = orcObject.idcardNo
    }
    if(orcObject.idcardAddress){
      applymentDetailInfo.idcardAddress = orcObject.idcardAddress
    }
    if(orcObject.idcardEffectBegin){
      applymentDetailInfo.idcardEffectBegin = orcObject.idcardEffectBegin
    }
    if(orcObject.idcardEffectEnd){
      applymentDetailInfo.idcardEffectEnd = orcObject.idcardEffectEnd
    }
  }
}

// 点击【保存】的前置事件, 需要返回Promise对象
function saveDataPreCallback(isTemp){

  // 放置费率配置项
  let paywayFeeList = jeepayPaywayRatePanelRef.value.getReqMchRatePaywayFeeList()
  if(typeof(paywayFeeList) != 'object'){
      return Promise.reject()
  }

  // 赋值到对象中
  applymentDetailInfo.paywayFeeList = paywayFeeList


  // 站点信息
  applymentDetailInfo.feeData = vdata.receiverTableData

  // 用于进件列表【进件商户名】的展示
  if(!applymentDetailInfo.mchFullName) {
    applymentDetailInfo.mchFullName = applymentDetailInfo.mchShortName
  }

  // 保存草稿只校验当前步骤数据
  if (isTemp) {
    return Promise.resolve()
  }

  // 验证所有表单
  return validateAllForm(1).then(() => {
    return Promise.resolve()
  }).catch((params: any) => {
    $infoBox.message.error('数据填写不完整， 请检查后提交')
    return Promise.reject()
  })
}


// 商户经营地省市县 回调
function searchAreaFunc(value) {
  if (applymentDetailInfo.address) {
    applymentDetailInfo.address = ''
  }
  if (value.length) {
    if (value.length == 2) {
      applymentDetailInfo.address = value[0].label + '' + value[1].label + ''
    } else if (value.length == 3) {
      applymentDetailInfo.address = value[0].label + '' + value[1].label + '' + value[2].label + ''
    }
  }
}

// 当商户类型发送改变时清除微信经营类目、初始化结算账户类型
function mchTypeChange(){
  applymentDetailInfo.wxMccCode = ''
  if (applymentDetailInfo.merchantType == '1') {
    // 小微类型商户只能结算到法人账户
    applymentDetailInfo.settAccountType = 'C'
  } else {
    applymentDetailInfo.settAccountType = ''
  }
}

// 将法人信息填入到指定地方
function isLegal(type){
  if (type) {
    if (type == 'contact') {
      // 将法人信息填入到商户联系人中
      applymentDetailInfo.contactName = applymentDetailInfo.idcardName
      applymentDetailInfo.contactPhone = applymentDetailInfo.legalPersonPhone
      applymentDetailInfo.serviceTel = applymentDetailInfo.legalPersonPhone
    }
  }
}

defineExpose({ saveDataPreCallback })

</script>

<style lang="less" scoped>
.jeepay-tip-text{
  font-size: 10px; color: rebeccapurple
}
.option-left {
  width: 50%;
  word-wrap: break-word; 
  white-space: normal;
  word-break: break-all;
}
.option-right {
  color: rgb(153, 153, 153);
}
.option-bottom {
  word-wrap: break-word; 
  white-space: normal;
  word-break: break-all;
  color: rgb(153, 153, 153);
}
.jeepay-btn-box {
  margin: 15px -12px !important;
}
.jeepay-btn-box .ant-btn {
  margin: 0 10px;
}
</style>